package com.cloud.zuul.init;

import com.cloud.zuul.core.ConfigLoader;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;

@Component
public class AppInitializer implements ApplicationListener<ContextRefreshedEvent> {

    private boolean started;

    @Autowired
    private ConfigLoader configLoader;

    @Override
    public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
        if (started) {
            return;
        }
        started = true;
        configLoader.load();
    }
}
